﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TS.Bussiness;
using TS.Commons;
using TS.Entities;

namespace Tranco
{
    public partial class NumberBikeDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["TracoUserId"] == null)
                {
                    ClientAlert("Đăng nhập để xem thông tin lịch trình.");
                    return;
                }

                HiddenFieldId.Value = Request.QueryString["nbid"];
                LoadNumberBike();
            }
        }

        private void LoadNumberBike()
        {
            NumberBikeBussiness bu = new NumberBikeBussiness();
            NumberBike obj = bu.GetNumberBikeById(HiddenFieldId.Value.ToNumeric());

            txtNumber.Text = obj.NumberPlate;
            txtName.Text = obj.Name;
            txtTel.Text = obj.Tel;
            txtDescription.Text = obj.Description;

        }

        public void ClientAlert(string strAlert)
        {
            var strScript = new StringBuilder();
            strScript.Append("<script language=JavaScript>");
            string scriptString = string.Format(CultureInfo.CurrentCulture, @"window.alert('" + strAlert + "');</script> ");
            strScript.Append(scriptString);
            ClientScript.RegisterStartupScript(GetType(), "Pop", strScript.ToString());
        }
    }
}